<?php
global $_GPC, $_W;
$uniacid = $_W['uniacid'];
$op = $_GPC['op'];
$openid = $_GPC['openid'];
$id = $_GPC['id'];
$res = $this->res;
$plus = $this->plus;
load()->func('tpl');
$setting = $this->baseset($uniacid);
$settings = $this->module['config'];
if ($setting['fltype'] == 1) {
	$ddbili = $setting['ddbili'];
} else {
	$ddbili = $setting['ddbili'] / 100;
}
$user = pdo_fetch("SELECT * FROM " . tablename($this->tableuser) . " WHERE uniacid = '{$_W['uniacid']}' AND openid = '{$openid}'");
if (!$user) {
	exit(json_encode(array('status' => '500')));
}
if ($_W['ispost'] && $op == 'list') {
	$nowpage = $_GPC['limit'];
	$pindex = max(1, intval($nowpage));
	$psize = 10;
	$list = pdo_fetchall("SELECT * FROM " . tablename($this->tableorderus) . " WHERE uniacid = :uniacid AND openid=:openid AND queren = 0 LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':uniacid' => $uniacid, ':openid' => $openid));
	if (!empty($list)) {
		foreach ($list as $key => $value) {
			$list[$key]['thisorder'] = pdo_fetch("SELECT * FROM " . tablename($this->tableorder) . " WHERE uniacid = '{$_W['uniacid']}' AND orderid = '{$list[$key]['orderid']}'");
			$list[$key]['time'] = date('Y-m-d', $list[$key]['ctime']);
			if ($list[$key]['thisorder']['orderstatus'] == '订单付款') {
				if ($setting['fltype'] == 1) {
					$list[$key]['fl'] = "预奖励" . $list[$key]['thisorder']['shouru_yongjin'] * $ddbili . "积分";
				} else {
					$list[$key]['fl'] = "预奖励" . round($list[$key]['thisorder']['shouru_yongjin'] * $ddbili, 2) . "元宝";
				}
			} elseif ($list[$key]['thisorder']['orderstatus'] == '订单失效') {
				$list[$key]['fl'] = "订单失效";
			} else {
				$list[$key]['fl'] = "暂无匹配";
			}
		}
		$sta = 200;
	} else {
		$sta = -103;
	}
	exit(json_encode(array('status' => $sta, 'content' => $list)));
}
include $this->template('uc_dd_dcl');